#include <SDL.h>
#include "Controller.h"
Controller::Controller() {
	m_keyMap.jump =false;
	m_keyMap.left = false;
	m_keyMap.right = false;
	m_keyMap.reset = false;
}
Controller::~Controller() {
}
bool Controller::poll() { // returns false is program should end
	SDL_Event event;
	while ( SDL_PollEvent( &event ) ) {
		switch ( event.type ) {
			case SDL_QUIT:
				return false; // signals quit
				break;
		} // end switch
		switch ( event.key.keysym.sym ) {
			case SDLK_ESCAPE:
				return false; // signals quit
				break;
			case SDLK_w:
			case SDLK_UP:
				m_keyMap.jump = (event.type == SDL_KEYDOWN);
				break;
			case SDLK_LEFT:
			case SDLK_a:
				m_keyMap.left = (event.type == SDL_KEYDOWN);
				break;		
			case SDLK_RIGHT :
			case SDLK_d:
				m_keyMap.right = (event.type == SDL_KEYDOWN);
				break;
			case SDLK_SPACE:
			case SDLK_r:
				m_keyMap.reset = (event.type == SDL_KEYDOWN);
				break;
		}
	} // end of message processing
	return true;
}
